package com.cqw.order.domain;

import com.cqw.order.enums.SpuStateEnum;
import com.cqw.vo.order.SpuReq;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

@ApiModel(value = "com.generation.domain.Spu")
@Data
@NoArgsConstructor
public class Spu implements Serializable {
    @ApiModelProperty(value = "id")
    private Long id;

    @ApiModelProperty(value = "shopId店铺id")
    private Long shopId;

    @ApiModelProperty(value = "spuName商品名称")
    private String spuName;

    @ApiModelProperty(value = "itemId商品分类id")
    private Long itemId;

    @ApiModelProperty(value = "title商品主标题")
    private String title;

    @ApiModelProperty(value = "subTitle商品副标题")
    private String subTitle;

    @ApiModelProperty(value = "spuPic商品轮播图，逗号分割")
    private String spuPic;

    @ApiModelProperty(value = "spuImg商品详情图，逗号分割")
    private String spuImg;

    @ApiModelProperty(value = "soldNum销量")
    private Integer soldNum;

    @ApiModelProperty(value = "totalStocks总库存")
    private Integer totalStocks;

    @ApiModelProperty(value = "state0已删除，1未上架，2已上架")
    private SpuStateEnum state;

    @ApiModelProperty(value = "onLineTime上架时间")
    private Date onLineTime;

    @ApiModelProperty(value = "createTime创建时间")
    private Date createTime;

    @ApiModelProperty(value = "updateTime修改时间")
    private Date updateTime;

    @ApiModelProperty(value = "description商品详情")
    private String description;


    public Spu(SpuReq spuReq) {
        this.id = spuReq.getId();
        this.shopId = spuReq.getShopId();
        this.spuName = spuReq.getSpuName();
        this.itemId = spuReq.getItemId();
        this.title = spuReq.getTitle();
        this.subTitle = spuReq.getSubTitle();
        this.spuPic = spuReq.getSpuPic();
        this.spuImg = spuReq.getSpuImg();
        this.description = spuReq.getDescription();
        this.state = spuReq.getState() == null ? SpuStateEnum.NO_LINE : spuReq.getState();
        this.createTime = new Date();
        this.updateTime = new Date();
    }
}



